package user;

import java.util.Hashtable;
import java.util.List;

import com.atlassian.crowd.exception.ApplicationPermissionException;
import com.atlassian.crowd.exception.InvalidAuthenticationException;
import com.atlassian.crowd.exception.OperationFailedException;
import com.atlassian.crowd.exception.UserNotFoundException;
import com.atlassian.crowd.model.group.Group;
import com.atlassian.crowd.model.user.User;

public class AdvanceUserInfoRetriever {

	/*
	 * This search methods return users who their username matches the search terms together with the 
	 */
	
	public  Hashtable searchUserInfo(String searchText) throws OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException, UserNotFoundException {
		RetrieveUserInfo userInfo = new RetrieveUserInfo();
		List  users= userInfo.searchUsers(searchText); 
		
		Hashtable userGroups = new Hashtable();
		
		//System.out.println(users);
		for (int i = 0; i<users.size(); i++){
			User u = (User) users.get(i);
			List<String> grps = userInfo.getNamesOfGroupsForUser(u.getName()); 
			userGroups.put(u.getDisplayName(), grps);
			
		}
		System.out.println(userGroups );
		return userGroups;

	}
}
